home *** CD-ROM | disk | FTP | other *** search
/ Maclife 22 / MACLIFE22-No-102-1997.ISO.7z / MACLIFE22-No-102.ISO / 連載 / Creators Room / Klik & Play / Klik & Play DEMO / Gamepack / SLOTUK40.txt < prev    next >
Text File  |  1996-07-26  |  6KB  |  130 lines

  1. SLOT MACHINE
  2.  
  3.  
  4. The purse on the right shows how much money the player has to gamble with.
  5.  
  6. To start a game put some money in the machine by clicking on either a 」 coin or a 10p piece.  One credit (a game) costs 10p.
  7.  
  8. The credit light at the top of the machine shows how many games are left.
  9.  
  10. To start the reels rolling click on the green START button.  A reel can be prevented from rolling by pressing the associated HOLD button.  This option is only available at random times during the game.
  11.  
  12. When three types of fruit line up as shown on the chart the appropriate amount is added to the bank.  If two out of the three fruits line up then half the points are awarded.
  13.  
  14. For every 」1 you win one coin on the treasure trial lights up.  After every game, while there is money in the bank, the red COLLECT button flashes.  When this button is pressed all the money in the bank is put into the purse and the treasure trail lights go out.
  15.  
  16. When the player's game credits have run out they must use more from their purse.  Alternatively they can play using money from their bank by pressing the green flashing START button instead of COLLECT.
  17.  
  18.  
  19. Winning combinations
  20. Three Cherries      10p        Two Cherries          5p
  21. Three Melons        20p        Two Melons           10p
  22. Three Lemons        30p        Two Lemons           15p
  23. Three Plums            40p        Two Plums            20p
  24. Three Pears            50p        Two Pears            25p
  25. Three Bells            70p        Two Bells            35p
  26. Three Bars              」1        Two Bars             50p
  27. Three Double Bars    」2        Two Double Bars    」1
  28.  
  29. How I wrote the Slot Machine
  30.  
  31. Version 1,
  32.  
  33. The first version of the slot machine had eight different 32 by 30 active objects, one for each type of fruit.  These objects were copied three times, one for each reel.
  34.  
  35. A mask was then positioned over each of the reels, with a small area the size of the reel transparent, thus showing the fruit objects underneath.
  36.  
  37. To determine a winning sequence was very simple. For example, for a line of cherries the following would be used:
  38.  
  39. if number of "cherries" in zone (bar) = 3 then win situation
  40.  
  41. Although this gave maximum control over the fruit movement the large number of masked objects caused the slot machine to run too slowly.
  42.  
  43. Instead...
  44.  
  45. Version 2,
  46.  
  47. The solution was to replace the 24 fruit objects and three large mask objects with three smaller objects.  This was achieved by pre-calculating all the possible reel positions.
  48.  
  49. Having eight fruits, each 32 pixels high, gives a total reel size of 256 pixels.  Active objects can have 32 different direction frames, which means that to display the whole reel each fruit must move 8 pixels at a time.
  50.  
  51. (256 pixels / 32 frames = 8 pixels/frame.)
  52.  
  53. Once the reel frames have been generated a reel can be spun by simply repeatedly incrementing the direction:
  54.     "Fruits #1":    set direction dir("Fruits #1") + 1.
  55.  
  56. Having a single combination of fruits would result in a very predictable slot machine, so to add variety two additional reel fruit combinations were created. See objects "Fruits #1", "Fruits #2", and "Fruits #3".
  57.  
  58. Each reel can be one of "Fruits #1", "Fruits #2" or "Fruits #3".
  59.  
  60. Next, winning sequences need to be determined. This is considerably more difficult.
  61.  
  62. If    reel 1 is "Fruits #1" and direction is Cherries AND
  63.       reel 2 is "Fruits #1" and direction is Cherries AND
  64.       reel 3 is "Fruits #1" and direction is Cherries then WIN
  65.  
  66. If    reel 1 is "Fruits #2" and direction is Cherries AND
  67.       reel 2 is "Fruits #1" and direction is Cherries AND
  68.       reel 3 is "Fruits #1" and direction is Cherries then WIN
  69.  
  70. If    reel 1 is "Fruits #3" and direction is Cherries AND
  71.       reel 2 is "Fruits #1" and direction is Cherries AND
  72.       reel 3 is "Fruits #1" and direction is Cherries then WIN
  73.  
  74. etc.. (for all combinations of Fruits #1, 2 and 3 and for all directions)
  75.  
  76. Or more efficiently...
  77.  
  78. A fruit is fully visible every four direction frames (each fruit is 32 pixels high and moves 8 pixels at a time).  Therefore a variable (reel alterable value A) is set to the direction divided by 4, resulting in a value 0 to 7.
  79.  
  80. To decode the fruits a 菟seudo array” is created with active objects off-screen like this:
  81.  
  82.             Double bar    Bar              Cherries
  83.             Bar              Pear             Bar
  84.             Plum             Double bar    Double bar
  85.             Lemon         Lemon         Bell
  86.             Pear             Plum             Melon
  87.             Melon            Cherries      Lemon
  88.             Bell             Bell             Plum
  89.             Cherries      Melon            Pear
  90.  
  91. which represents the following array:
  92.  
  93.     Direction    Fruits #1    Fruits #2    Fruits #3
  94.     0        Double bar    Bar              Cherries
  95.     1        Bar              Pear             Bar
  96.     2        Plum             Double bar    Double bar
  97.     3        Lemon         Lemon         Bell
  98.     4        Pear             Plum             Melon
  99.     5        Melon            Cherries      Lemon
  100.     6        Bell             Bell             Plum
  101.     7        Cherries      Melon            Pear
  102.  
  103.  
  104. Next there are three active objects "Reel Score #1", "Reel Score #2" and "Reel Score #3" which act a pseudo array indexes.
  105.  
  106. The horizontal position of each "Reel Score" is determined by the type of fruit for each reel.
  107.  
  108. To decode the reel the vertical position of the Reel Score is moved according to the direction (a value between 0 and 7).  The resulting collision between the 迭eel Score” and the 吐ruit” is stored in an alterable value according to the fruit.
  109.  
  110. For example:
  111.  
  112. On starting the game if reel 2 used "Fruits #2" then "Reel Score #1" would be horizontally positioned above the second column.
  113.  
  114. Then during the game if the reel stopped on the melon, a direction value of 5, "Reel Score #1" would be positioned vertically at 160, 5 * 32.  The resulting collision with the "Melon" would set "Reel Score #1" alterable value A to 999.
  115.  
  116.  
  117. Finally to determine  a win the alterable value A of "Reel Score #1", "Reel Score #2" and "Reel Score #3" need to be checked for equality.
  118.  
  119.  
  120. if    "Reel Score #1" A is 10 and
  121.             "Reel Score #2" A is 10 and
  122.             "Reel Score #3" A is 10 then WIN
  123.  
  124. if    "Reel Score #1" A is 20 and
  125.             "Reel Score #2" A is 20 and
  126.             "Reel Score #3" A is 20 then WIN
  127.  
  128.  
  129. RichardG.
  130.